import { fabric } from 'fabric';

import ObjectPool from './ObjectPool';

class Circle extends fabric.Circle {
  constructor(options = {}) {
    const defaultOptions = {
      radius: 50,
      fill: '#ff6b81',
      stroke: '#333333',
      strokeWidth: 2,
      originX: 'center',
      originY: 'center',
      id: '',  // 添加id属性
    };

    super({
      ...defaultOptions,
      ...options,
    });
      // 确保控制点颜色与边框颜色一致
      this.set({
        cornerColor: this.stroke,
        borderColor: this.stroke,
      });
    this.setCoords();
  }
}

// 创建一个全局的圆形对象池
const circlePool = new ObjectPool(() => new Circle());

// 导出Circle类和circlePool
export { Circle, circlePool };
export default Circle;
